﻿<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <meta name="renderer" content="webkit">
    <title>大众之旅</title>
    <link href="/static/home/css/normalize.css" rel="stylesheet">
    <link href="/static/home/css/bootatrap/bootstrap.min.css" rel="stylesheet">
    <link href="/static/home/css/style.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/static/h-ui/css/H-ui.min.css" />
    <style>
        body {
            background-color: #f4f4f4;
        }
        .c-red{
            color:red !important;
        }
    </style>
</head>

<body>
    <!-- 注册 -->
    <div class="register clearfix">
        <div class="typearea">
            <div class="top">
                <img src="/static/home/img/logo2.jpg" alt="">
                <span class="name">中国生态农副产品商城</span>
                <div class="fr">
                    <span>我有账户</span>
                    <a href="login.html">立即登录</a>
                </div>
            </div>
            <div class="center">
                <form id="form-admin-add">
                    <div class="item">
                        <span class="c-red">*</span><span>用&nbsp;&nbsp;户&nbsp;&nbsp;&nbsp;名 </span>
                        <div class="form-group">
                            <input type="text" class="form-control" name="username" placeholder="请输入用户名">
                        </div>
                    </div>
                    <div class="item">
                        <span class="c-red">*</span><span>设&nbsp;置&nbsp;密&nbsp;码 </span>
                        <div class="form-group">
                            <input type="password" class="form-control" name="password" placeholder="请输入密码">
                        </div>
                    </div>
                    <div class="item">
                        <span class="c-red">*</span><span>确&nbsp;认&nbsp;密&nbsp;码 </span>
                        <div class="form-group">
                            <input type="password" class="form-control" name="confirm_password" placeholder="请确认密码">
                        </div>
                    </div>
                    <div class="item">
                        <span class="c-red">*</span><span>手&nbsp;机&nbsp;号&nbsp;码 </span>
                        <div class="form-group">
                            <input type="number" class="form-control" name="phone" placeholder="请输入手机号码">
                        </div>
                    </div>
                    <div class="item">
                        <span>&nbsp;&nbsp;&nbsp;邀&nbsp;&nbsp;请&nbsp;&nbsp;&nbsp;码 </span>
                        <div class="form-group">
                            <input type="text" class="form-control" name="invite_code" placeholder="请输入邀请码">
                        </div>
                    </div>
                    <div class="submit">
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" style="position:unset;"> 我已阅读并同意
                            </label>
                            <a><span>&lt;&lt;用户注册协议&gt;&gt;</span></a>
                            </div>
                            <button type="submit" class="btn btn-default">立即注册</button>
                    </div>
                </form>
            </div>
            <div class="copyright">
                版权所有 © 2004-2020 大众之旅官方商城  鄂ICP备00000000号
            </div>
        </div>
    </div>
    <script src="/static/home/js/bootstrap/jquery.min.js"></script>
    <script src="/static/home/js/bootstrap/bootstrap.min.js"></script>
    <script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
    <script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
    <script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript" src="/static/js/layer.js"></script>
    <script type="text/javascript" src="/static/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="/static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript">
    $(function(){
        $("#form-admin-add").validate({
            rules:{
                username:{
                    required:true,
                    minlength:4,
                    maxlength:16
                },
                password:{
                    required:true,
                    minlength:6,
                    maxlength:16
                },
                confirm_password:{
                    required:true,
                    minlength:6,
                    maxlength:16
                },
                phone:{
                    required:true,
                    minlength:11,
                    maxlength:11
                },
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var checked=$("input[type='checkbox']").is(':checked');
                if (checked) {
                    $(form).ajaxSubmit({
                        type: 'post',
                        url: "{:url('register')}",
                        success: function(data){
                            console.log(data)
                            if(data.code==200){
                                window.localStorage.setItem("Token",data.data.Token);
                                window.location.href="{$url}/shop/index/index.html"
                            }else{
                                layer.msg(data.msg,{icon:2,time:3000});
                            }

                        }
                    });
                }else{
                    layer.msg('未勾选用户协议',{icon:2,time:3000});
                }
                
            }
        });
    });
    </script>
</body>

</html>